package cn.edu.hunau.java.week03.day02;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

public class FilterRice {
    public static List<Rice> filter(List<Rice> datas, String filter){
        List<Rice> result=new ArrayList<>();
        for(Rice rice:datas){
            if(Boolean.parseBoolean(filter)){
                result.add(rice);
            }
        }
        return result;
    }
    public static <R> List<R> map(List<Rice> datas, Function<Rice,R> fun){
        List<R> result=new ArrayList<>();
        for(Rice rice:datas){
            result.add(fun.apply(rice));
        }
        return result;
    }
}
